home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / LIB / DRAG_ICO.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  5.3 KB  |  144 lines

  1.  
  2. package sub_arctic.lib;
  3.  
  4. import sub_arctic.lib.sub_arctic_error;
  5. import sub_arctic.output.loaded_image;
  6. import sub_arctic.output.drawable;
  7. import sub_arctic.input.move_press_draggable;
  8. import sub_arctic.input.event;
  9. import java.awt.Point;
  10.  
  11. /** 
  12.  * An icon (displayed image) object which can be dragged.  (This could also be
  13.  * done by placing an icon in a drag_container, but since this was built first
  14.  * and is more compact, we leave it.)
  15.  *
  16.  * @author Scott Hudson
  17.  */
  18. public class drag_icon extends icon implements move_press_draggable {
  19.  
  20.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  21.  
  22.   /** 
  23.    * Full constructor.  
  24.    * @param int          x   initial x position of the object.
  25.    * @param int          y   initial y position of the object.
  26.    * @param loaded_image img the image to display for the icon.
  27.    */
  28.   public drag_icon(int x, int y, loaded_image img) 
  29. {
  30.       super(x,y,img);
  31.     }
  32.  
  33.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  34.  
  35.   /** 
  36.    * Handle the start of a drag to the object.  
  37.    * 
  38.    * @param event  evt       the event "causing" the start of the drag.
  39.    * @param int    xv        the new x position of this object (in parent's 
  40.    *                         coords).   
  41.    * @param int    yv        the new y position of this object (in parent's 
  42.    *                         coords).   
  43.    * @param int    gx        the initial grab x position of the drag (in local 
  44.    *                         coords).
  45.    * @param int    gy        the initial grab x position of the drag (in local 
  46.    *                         coords).
  47.    * @param Object user_info information associated with this object at the 
  48.    *                         time it requested the drag focus.
  49.    */
  50.   public boolean drag_start(
  51.     event evt, int xv, int yv, int gx, int gy, Object user_info)
  52.     {
  53.       /* move our position */
  54.       set_pos(xv,yv);
  55.       return true;
  56.     }
  57.  
  58.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  59.  
  60.   /** 
  61.    * Handle a movement during a drag.  Here we just set our position to 
  62.    * follow the event location. 
  63.    * 
  64.    * @param event  evt       the event "causing" the start of the drag.
  65.    * @param int    x_pos     the new x position of this object (in parent's 
  66.    *                         coords).   
  67.    * @param int    y_pos     the new y position of this object (in parent's 
  68.    *                         coords).   
  69.    * @param int    start_x   the initial grab x position of the drag (in local 
  70.    *                         coords).
  71.    * @param int    start_y   the initial grab x position of the drag (in local 
  72.    *                         coords).
  73.    * @param int    grab_x    the initial grab x position of the drag (in local 
  74.    *                         coords).
  75.    * @param int    grab_y    the initial grab x position of the drag (in local 
  76.    *                         coords).
  77.    * @param Object user_info information associated with this object at the 
  78.    *                         time it requested the drag focus.
  79.    */
  80.   public boolean drag_feedback(
  81.     event evt,
  82.     int x_pos, int y_pos,
  83.     int start_x, int start_y,
  84.     int grab_x, int grab_y,
  85.     Object user_info)
  86.     {
  87.  
  88.       /* move our position */
  89.       set_pos(x_pos, y_pos);
  90.       return true;
  91.     }
  92.  
  93.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  94.  
  95.   /** 
  96.    * Handle input corresponding to the end of a drag.  
  97.    *
  98.    * @param event  evt       the event "causing" the start of the drag.
  99.    * @param int    x_pos     the new x position of this object (in parent's 
  100.    *                         coords).   
  101.    * @param int    y_pos     the new y position of this object (in parent's 
  102.    *                         coords).   
  103.    * @param int    start_x   the initial grab x position of the drag (in local 
  104.    *                         coords).
  105.    * @param int    start_y   the initial grab x position of the drag (in local 
  106.    *                         coords).
  107.    * @param int    grab_x    the initial grab x position of the drag (in local 
  108.    *                         coords).
  109.    * @param int    grab_y    the initial grab x position of the drag (in local 
  110.    *                         coords).
  111.    * @param Object user_info information associated with this object at the 
  112.    *                         time it requested the drag focus.
  113.    */
  114.   public boolean drag_end(
  115.     event evt,
  116.     int x_pos, int y_pos,
  117.     int start_x, int start_y,
  118.     int grab_x, int grab_y,
  119.     Object user_info)
  120.     {
  121.       /* let drag_feedback to all the work */
  122.       return drag_feedback(evt, x_pos, y_pos, start_x, start_y, grab_x, grab_y,
  123.                                     user_info);
  124.     }
  125.  
  126.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  127. }
  128. /*=========================== COPYRIGHT NOTICE ===========================
  129.  
  130. This file is part of the subArctic user interface toolkit.
  131.  
  132. Copyright (c) 1996 Scott Hudson and Ian Smith
  133. All rights reserved.
  134.  
  135. The subArctic system is freely available for most uses under the terms
  136. and conditions described in 
  137.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  138. and appearing in full in the lib/interactor.java source file.
  139.  
  140. The current release and additional information about this software can be 
  141. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  142.  
  143. ========================================================================*/
  144.